package com.example.online_exam_system.dao;

import com.example.online_exam_system.dto.QuestionsDto;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.PathVariable;

import java.util.List;
import java.util.Map;

/**
 * (TestQuestions)表数据库访问层
 *
 * @author lianglong@asiainfo.com
 * @since 2021-11-27 09:55:05
 */
public interface TestQuestionsDao {

    @Select("select * from test_questions")
    List<QuestionsDto> getQuestionsByTeacherId();

    @Insert("INSERT INTO test_questions (" +
            "stem,opta,optb,optc,optd,`right`,score,`analysis`,`type`,subjectid) " +
            "VALUES(#{inParam.stem},#{inParam.opta},#{inParam.optb},#{inParam.optc},#{inParam.optd},#{inParam.right},#{inParam.score}," +
            "#{inParam.analyse},#{inParam.type},#{inParam.subjectid})")
    int insertQuestion(@Param("inParam")QuestionsDto questionsDto);

    @Update("update test_questions set stem=#{inParam.stem}, opta=#{inParam.opta}, optb=#{inParam.optb},optc=#{inParam.optc},optd=#{inParam.optd}," +
            "`right` = #{inParam.right},score=#{inParam.score},analysis=#{inParam.analyse},`type`=#{inParam.type},subjectid=#{inParam.subjectid} where questionid=#{inParam.questionid} ")
    int updateQuestion(@Param("inParam")Map<String, Object> inParam);


    @Delete("delete from test_questions where questionid=#{inParam.questionid}")
    int deleteQuestion(@Param("inParam")Map<String, Object> inParam);

    @Select("select * from test_questions where subjectid = #{inParam.subjectid}")
    List<QuestionsDto> getQuestionsBySubjectId(@Param("inParam")Map<String, Object> inParam);

    @Select("Select * from test_questions where questionid = #{questionId}")
    Map<String, Object> getQuestionsByQuestionId(@Param("questionId") String questionId);
}


